package com.youwe.model.common;

import java.util.ArrayList;
import java.util.List;

public class PageModel<T> {

	/**
	 * 每页显示条数
	 */
	private int pageSize;

	/**
	 * 当前页
	 */
	private int currentPage;

	/**
	 * 查询总记录数
	 */
	private int totalCount;

	/**
	 * 查询总页数
	 */
	private int totalPage;

	/**
	 * 分页查询出来的数据
	 */
	private List<T> data = new ArrayList<T>();

	public List<T> getData() {
		return data;
	}

	public void setData(List<T> data) {
		this.data = data;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public int getTotalPage() {
		int min = totalCount / pageSize;
		int mod = totalCount % pageSize;
		if(min == 0 && mod == totalCount) {
			++min;
		}else if(mod > 0 && mod < totalCount) {
			++min;
		}
		return min;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}
}
